package com.wyl.xue.admin.conf;

import com.wyl.xue.core.util.SwaggerUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName: Swagger2Configuration
 * @Function: swaggerUi的配置
 * @Date: 2020/3/27 14:59
 * @author wangyl
 * @version V1.0
 */
@Configuration
@EnableSwagger2
public class AdminSwagger2Configuration {
    @Bean
    public Docket adminRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                                                      .select()
                                                      .apis(RequestHandlerSelectors.basePackage("com.wyl.xue.admin.controller"))
                                                      .paths(PathSelectors.any())
                                                      .build()
                                                      .securitySchemes(SwaggerUtil.swagger.securitySchemes())
                                                      .securityContexts(SwaggerUtil.swagger.securityContexts())
                                                      .groupName("admin");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("Xue管理系统接口文档")
                                   .description("Xue相关接口的文档")
                                   .termsOfServiceUrl("http://127.0.0.1:8080")
                                   .contact(new Contact("Fame-springBoot-Swagger2", null, null))
                                   .version("1.0")
                                   .build();
    }
}